package ai.plantdata.controller;

import ai.plantdata.service.WriteService;
import ai.plantdata.vo.SchemalVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: WangHui
 * @Date: 2021/7/9 10:25
 * @Description:
 */
@EnableAsync
@RestController
@RequestMapping("/create")
public class WriteController {
    @Autowired
    private WriteService writeService;

    @PostMapping("/schemal/{kgName}")
    public ResponseEntity<Void> createScemal(@PathVariable String kgName, @RequestBody SchemalVO schemalVO) {
        writeService.createSchemal(kgName, schemalVO);
        return ResponseEntity.status(HttpStatus.CREATED).build();
    }

    @PostMapping("/node/{kgName}")
    public ResponseEntity<Void> createNode(@PathVariable String kgName, @RequestBody SchemalVO schemalVO) {
        writeService.createNode(kgName, schemalVO);
        return ResponseEntity.status(HttpStatus.CREATED).build();
    }
}
